﻿using System;
using Garfield.Core.Runtime.SPI;

namespace Garfield.Core.Runtime
{
    [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
    public sealed class ExtensionPointAttribute : Attribute, IDependencyAttribute
    {
        public string Identifier { get; private set; }

        public ExtensionPointAttribute(string identifier)
        {
            Identifier = identifier;
        }

        object IDependencyAttribute.ProvideValue(IPlatformProvider platformProvider, Type expectedType)
        {
            return platformProvider.GetExtensions(Identifier);
        }
    }
}
